package com.viknix.threadpool.manager.common.config;

import com.viknix.threadpool.manager.common.model.PoolParameterInfo;
import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Dongqi
 * @Date: 2021/11/8 14:50
 * @Version 1.0
 * @Description: 校验分组器
 */
public class PoolParamterInfoGroupSequenceProvider implements DefaultGroupSequenceProvider<PoolParameterInfo> {

    @Override
    public List<Class<?>> getValidationGroups(PoolParameterInfo parameterInfo) {

        List<Class<?>> defaultGroupSequence = new ArrayList<>();
        defaultGroupSequence.add(PoolParameterInfo.class);

        if (parameterInfo != null) {
            if (parameterInfo.alert()) {
                defaultGroupSequence.add(PoolParameterInfo.Alert.class);
            }
        }
        return defaultGroupSequence;
    }
}
